/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import entities1.WeatherInformation;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author takamflore
 */
@Stateless
public class WeatherDaoImpl implements WeatherDao {
    
    @PersistenceContext(unitName = "meteoCal_PU")
    private EntityManager em;
    List<WeatherInformation> weathers;
    WeatherInformation weather;
    
    @Override
    public void addWeatherInfo(WeatherInformation weather){
       em.persist(weather);
    }
    @Override
   public List<WeatherInformation> allWeaterInformation(){
      weathers= em.createNamedQuery("WeatherInformation.findAll").getResultList();
       return weathers;
   }
   @Override
       public WeatherInformation checkWeatherInformationID(int id){
           weather= em.find(WeatherInformation.class, id);
           return weather;
       }
       
    @Override
    public WeatherInformation checkWeatherInformationString(String temperature){
        weather= em.find(WeatherInformation.class, temperature);
   
        return weather;
    }
}
